package com.example.modellol.Fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.modellol.R;
import com.example.modellol.adapter.MyAdapter2;
import com.example.modellol.adapter.MyAdapter4;
import com.example.modellol.bean.Gent;
import com.example.modellol.bean.News;

import java.util.ArrayList;

public class FouthFragment extends Fragment {

    private View view;
    public RecyclerView mCollectRecyclerView;
    private ArrayList<Gent> goodsEntityList = new ArrayList<Gent>();
    private MyAdapter4 mCollectRecyclerAdapter;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.item_genting, container, false);
        initRecyclerView();
        initData();
        return view;

    }

    int[] d =new int[]{R.drawable.gent_avatar_1, R.drawable.gent_avatar_2,
            R.drawable.gent_avatar_3, R.drawable.gent_avatar_4,
            R.drawable.gent_avatar_5, R.drawable.gent_avatar_6};

    int[] c =new int[]{R.drawable.gent_picture_1, R.drawable.gent_picture_2,
            R.drawable.gent_picture_3, R.drawable.gent_picture_4,
            R.drawable.gent_picture_5, R.drawable.gent_picture_6};

    String[] b=new String[]{"【天神裁决天使】 4裁决4天神2宗师","【重装拉夫】 4重装3龙魂3战神",
            "【七法龙王】 7魔法师3森林3龙魂","【重秘神射】 4神射2重装2秘术","【决斗宗师】 6决斗2玉剑2宗师",
            "【神盾凯南】 6神盾3森林3猩红"
    };

    String[] a=new String[]{"虎牙|king亚索","斗鱼|梨落秋溪",
            "斗鱼|迅哥、雨霖铃、、","虎牙、无敌李夫人","虎牙 宝子",
            "斗鱼|卷子"
    };
    private void initData() {
        goodsEntityList.clear();
        for(int i=0;i<6;i++){
            Gent goodsEntity=new Gent();
            goodsEntity.setText_1(b[i]);
            goodsEntity.setText_2(a[i]);
            goodsEntity.setPhoto_1(c[i]);
            goodsEntity.setPhoto_2(d[i]);
            goodsEntityList.add(goodsEntity);
        }
    }

    private void initRecyclerView() {
        mCollectRecyclerView = (RecyclerView) view.findViewById(R.id.g_recycle);
        mCollectRecyclerAdapter = new MyAdapter4(getActivity(), goodsEntityList);
        mCollectRecyclerView.setAdapter(mCollectRecyclerAdapter);
        mCollectRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        mCollectRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
        mCollectRecyclerAdapter.setOnItemClickListener(new MyAdapter4.OnItemClickListener() {
            @Override
            public void OnItemClick(View view, Gent data) {
                Toast.makeText(getActivity(), "我是item", Toast.LENGTH_SHORT).show();
            }
        });
    }
}

